In [ ]:
%matplotlib inline
%pylab inline

Load training data


In [ ]:
import menpo.io as mio
from menpo.landmark import labeller, streetscene_car_view_1
from menpofast.utils import convert_from_menpo

group = 'streetscene_car_view_1'

training_images = []
for i in mio.import_images('/data/PhD/DataBases/cars/cmu_car_data1/view1/',
                           verbose=True, max_images=None):
    
    # convert the image from menpo Image to menpofast Image (channels at front)
    i = convert_from_menpo(i)
    
    labeller(i, 'PTS', eval(group))
    i.crop_to_landmarks_proportion_inplace(1, group=group)
    i = i.rescale_landmarks_to_diagonal_range(200, group=group)
    
    if i.n_channels == 3:
        i = i.as_greyscale(mode='average')
    training_images.append(i)

In [ ]:
training_images = training_images[::2]

In [ ]:
from menpo.visualize import visualize_images

visualize_images(training_images)

AAMs

Build


In [ ]:
from menpofast.feature import no_op, fast_dsift, fast_daisy
from alabortcvpr2015.aam import PartsAAMBuilder

aam = PartsAAMBuilder(parts_shape=(17, 17),
                 features=fast_dsift,
                 diagonal=100,
                 normalize_parts=False,
                 scales=(1, .5),
                 max_shape_components=25,
                 max_appearance_components=250).build(training_images,
                                                      group=group,
                                                      verbose=True)

In [ ]:
from menpofast.image import Image

Image(aam.appearance_models[0].mean().pixels[5, 0]).view()

Save


In [ ]:
from alabortcvpr2015.utils import pickle_dump

pickle_dump(aam, '/data/PhD/Models/aam_view1_fast_dsift')